#----------------------------------*-sh-*--------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
#   \\  /    A nd           | www.openfoam.com
#    \\/     M anipulation  |
#------------------------------------------------------------------------------
#     Copyright (C) 2016 OpenFOAM Foundation
#     Copyright (C) 2016-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
#     This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
#     etc/config.csh/compiler
#     - sourced by OpenFOAM-*/etc/config.csh/settings
#
# Description
#     Setup for custom compiler versions for OpenFOAM
#     Per-compiler overrides in "compiler-$WM_COMPILER" files
#
# Note
#     The default values for gcc/clang are not a recommendation,
#     but typically correspond to the minimum usable version.
#
#------------------------------------------------------------------------------

switch ("$WM_COMPILER_TYPE")
case ThirdParty:
    # Default versions (CLANG, GCC, GMP, MPFR, MPC) - override as necessary

    set default_clang_version=llvm-3.7.1
    set default_gcc_version=gcc-4.8.5

    set default_gmp_version=gmp-system
    set default_mpfr_version=mpfr-system
    set default_mpc_version=mpc-system

    switch ("$WM_COMPILER")
    case Gcc:
        set gcc_version="$default_gcc_version"
        breaksw
    case Gcc101*:
        set gcc_version=gcc-10.1.0
        breaksw
    case Gcc93*:
        set gcc_version=gcc-9.3.0
        breaksw
    case Gcc92*:
        set gcc_version=gcc-9.2.0
        breaksw
    case Gcc91*:
        set gcc_version=gcc-9.1.0
        breaksw
    case Gcc84*:
        set gcc_version=gcc-8.4.0
        breaksw
    case Gcc83*:
        set gcc_version=gcc-8.3.0
        breaksw
    case Gcc82*:
        set gcc_version=gcc-8.2.0
        breaksw
    case Gcc81*:
        set gcc_version=gcc-8.1.0
        breaksw
    case Gcc75*:
        set gcc_version=gcc-7.5.0
        breaksw
    case Gcc74*:
        set gcc_version=gcc-7.4.0
        breaksw
    case Gcc73*:
        set gcc_version=gcc-7.3.0
        breaksw
    case Gcc72*:
        set gcc_version=gcc-7.2.0
        breaksw
    case Gcc71*:
        set gcc_version=gcc-7.1.0
        breaksw

    # Older GCC series that receive no further bugfixes
    case Gcc65*:
        set gcc_version=gcc-6.5.0
        breaksw
    case Gcc64*:
        set gcc_version=gcc-6.4.0
        breaksw
    case Gcc63*:
        set gcc_version=gcc-6.3.0
        breaksw
    case Gcc62*:
        set gcc_version=gcc-6.2.0
        breaksw
    case Gcc61*:
        set gcc_version=gcc-6.1.0
        breaksw
    case Gcc55*:
        set gcc_version=gcc-5.5.0
        breaksw
    case Gcc54*:
        set gcc_version=gcc-5.4.0
        breaksw
    case Gcc53*:
        set gcc_version=gcc-5.3.0
        breaksw
    case Gcc52*:
        set gcc_version=gcc-5.2.0
        breaksw
    case Gcc51*:
        set gcc_version=gcc-5.1.0
        breaksw
    case Gcc49*:
        set gcc_version=gcc-4.9.4
        breaksw
    case Gcc48*:
        set gcc_version=gcc-4.8.5
        breaksw

    case Clang:
        set clang_version="$default_clang_version"
        breaksw
    case Clang100*:
        set clang_version=llvm-10.0.0
        breaksw
    case Clang90*:
        set clang_version=llvm-9.0.1
        breaksw
    case Clang80*:
        set clang_version=llvm-8.0.1
        breaksw
    case Clang71*:
        set clang_version=llvm-7.1.0
        breaksw
    case Clang70*:
        set clang_version=llvm-7.0.1
        breaksw
    case Clang60*:
        set clang_version=llvm-6.0.1
        breaksw
    case Clang50*:
        set clang_version=llvm-5.0.2
        breaksw
    case Clang40*:
        set clang_version=llvm-4.0.1
        breaksw
    case Clang39*:
        set clang_version=llvm-3.9.1
        breaksw
    case Clang38*:
        set clang_version=llvm-3.8.1
        breaksw
    case Clang37*:
        set clang_version=llvm-3.7.1
        breaksw

    default:
        /bin/cat << UNKNOWN_COMPILER
===============================================================================
Warning in $WM_PROJECT_DIR/etc/config.csh/compiler:
Unknown ThirdParty compiler type/version - '$WM_COMPILER'

Please check your settings
===============================================================================
UNKNOWN_COMPILER
        breaksw
    endsw

    # Per-compiler overrides in "compiler-$WM_COMPILER" files
    _foamEtc -config "compiler-$WM_COMPILER"
    breaksw
endsw

unset default_gcc_version default_clang_version
unset default_gmp_version default_mpfr_version default_mpc_version

#------------------------------------------------------------------------------
